﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Schema;
using System.Reflection;
using System.IO;
using System.Xml;

namespace Barbar.UrlGuard.BL.Concrete {
  internal class LanguageSchemaProvider : ILanguageSchemaProvider {
    #region ILanguageSchemaProvider Members

    public XmlSchema GetSchema() {
      Assembly assembly = Assembly.GetExecutingAssembly();
      XmlSchema result = null;
      using (Stream stream = assembly.GetManifestResourceStream("Barbar.UrlGuard.Resources.Languages.language.xsd")) {
        if (stream == null) {
          throw new Exception("Resource not found, assembly propably corrupted.");
        }
        using (XmlReader reader = XmlReader.Create(stream)) {
          result = XmlSchema.Read(reader, null);
        }
      }

      return result;
    }

    #endregion
  }
}
